package com.zring.service.impl;

import com.zring.dao.m2.TeacherDao;
import com.zring.dao.m1.UserDao;
import com.zring.model.m1.User;
import com.zring.model.m2.Teacher;
import com.zring.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
public class CommonServiceImpl implements CommonService {

    @Autowired
    private UserDao userDao;

    @Autowired
    private TeacherDao teacherDao;

    @Transactional
    public void insert() {
        User user = new User("m1", 28);
        userDao.insertUser(user);
        if(user.getAge() != 28)
            throw new RuntimeException("发生错误了");
        teacherDao.insertTeacher(new Teacher("m2", 18));
    }
}
